package com.xuecheng.content.controller;


import com.xuecheng.commons.model.dto.TeachplanDto;
import com.xuecheng.commons.model.vo.ResponseResult;
import com.xuecheng.commons.model.vo.TeachplanVo;
import com.xuecheng.content.service.TeachplanService;
import lombok.extern.slf4j.Slf4j;
import org.simpleframework.xml.Path;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程计划 前端控制器
 * </p>
 *
 * @author itheima
 * @since 2024-05-03
 */
@Slf4j
@RestController
public class TeachplanController {

    @Autowired
    private TeachplanService teachplanService;

    /*
    * 查询课程计划
    * */
    @GetMapping("/teachplan/{courseId}/tree-nodes")
    public ResponseResult<TeachplanVo> treeNodes(@PathVariable("courseId") Long courseId){
        return teachplanService.treeNodes2(courseId);
    }
    /*
    * 删除课程计划
    * */
    @DeleteMapping("/teachplan/{id}")
    public ResponseResult deleteTeachplan(@PathVariable("id") Long teachplanId){
        return teachplanService.deleteTeachplan(teachplanId);
    }

    /*
    * 新增或修改课程计划
    * */
    @PostMapping("/teachplan")
    public ResponseResult saveOrderUpdateTeachplan(@RequestBody TeachplanDto dto){
        return teachplanService.saveOrUpdateTeachplan(dto);
    }

}
